<?php



require_once(dirname(__FILE__)."/../include/common.inc.php");
require_once(DEDEINC.'/enums.func.php');
require_once(dirname(__FILE__)."/../include/province_short.inc.php");
require_once(dirname(__FILE__)."/../include/province_picture.inc.php");
if(empty($dopost)) $dopost = '';

// setcookie('history_id','1,11,9');

// 通过cookie获取最近浏览的院校的id
$history_id = rtrim($history_id,',');
$history_ids = explode(',', $history_id);
$history_ids_str = join(',',$history_ids);
// 获取最佳浏览的院校的数组
$sql = "SELECT * FROM `#@__collegeinfo` WHERE  collegeId IN ($history_ids_str)";
$dsql->SetQuery($sql);
$dsql->Execute();
$history_college = array();
while($row = $dsql->GetArray()){
    $history_college[] = $row;
}

// 推荐院校的数组
$recommend_college = CollegeRecommend($history_ids);


/**
 * 根据最近浏览院校的推荐函数，根据最多的学费范围，地区推荐
 * $history_college  最近浏览院校数组
 * return  推荐院校的数组
 * by HehongChen
 * 2014.10.30
 */
function CollegeRecommend($history_ids){
	global $dsql;
	$history_ids_str = join(',',$history_ids);
	// 获取院校中最多的学费范围和地区
	$sql_max_feerange = "SELECT feeRange FROM `#@__collegeinfo` WHERE collegeId IN ($history_ids_str) group by feeRange order by count(feeRange) desc limit 1";
	$dsql->SetQuery($sql_max_feerange);
	$dsql->Execute();
	$max_feerange_arr = $dsql->GetArray();
	$max_feerange = $max_feerange_arr['feeRange'];

	$sql_max_area = "SELECT area FROM `#@__collegeinfo` WHERE collegeId IN ($history_ids_str) group by area order by count(area) desc limit 1";
	$dsql->SetQuery($sql_max_area);
	$dsql->Execute();
	$max_area_arr = $dsql->GetArray();
	$max_area = $max_area_arr['area'];

	// // 构造查询的sql语句
	$sql = "SELECT * FROM `#@__collegeinfo` WHERE  feeRange=$max_feerange AND area=$max_area AND collegeId NOT IN ($history_ids_str)";
	$dsql->SetQuery($sql);
	$dsql->Execute();
	$recommend_college = array();
	while($row = $dsql->GetArray()){
    	$recommend_college[] = $row;
	}

	return $recommend_college;
}


// 联系我们传参开始

$sql = "select * from  `#@__contact` where 1";
$dsql->SetQuery($sql);
$dsql->Execute();

$contact  = array();
while($row = $dsql->GetArray()){
$contact[] = $row;
}



// 联系我们传参结束

//显示模板(简单PHP文件)
include_once(DEDETEMPLATE.'/plus/college_list.htm');

?>